<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8">
        <!-- 加入对静态文件路径的支持 -->
        {% load static %}

        <title>数据系统服务平台pos</title>
        <meta name="base_title" content="Charisma测试系统" />
        <!-- The styles -->
        <link id="bs-css" href="{% get_static_prefix %}charisma/css/bootstrap-cerulean.css" rel="stylesheet">
        <style type="text/css">  
          body {
                padding-bottom: 40px;
          }
          .sidebar-nav {
                padding: 9px 0;
          }
        </style>
        <link href="{% get_static_prefix %}charisma/css/bootstrap-responsive.css" rel="stylesheet">
        <link href="{% get_static_prefix %}charisma/css/charisma-app.css" rel="stylesheet">
        <link href="{% get_static_prefix %}charisma/css/jquery-ui-1.8.21.custom.css" rel="stylesheet">
        <link href='{% get_static_prefix %}charisma/css/fullcalendar.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/fullcalendar.print.css' rel='stylesheet'  media='print'>
        <link href='{% get_static_prefix %}charisma/css/chosen.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/uniform.default.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/colorbox.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/jquery.cleditor.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/jquery.noty.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/noty_theme_default.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/elfinder.min.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/elfinder.theme.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/jquery.iphone.toggle.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/opa-icons.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/uploadify.css' rel='stylesheet'>

        <!-- easy UI -->
        <link rel="stylesheet" type="text/css" href="{% get_static_prefix %}css/easyui/default/easyui.css"/> 
        <!-- 
        <link rel="stylesheet" type="text/css" href="{% get_static_prefix %}css/easyui/icon.css"/> 
        -->
        <!-- our own code -->
        <link href='{% get_static_prefix %}css/other.css' rel='stylesheet'>



        <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->


        <!-- The fav icon -->
        <link rel="shortcut icon" href="{% get_static_prefix %}charisma/img/favicon.ico">

</head>

<body>
	<div>
		<ul class="breadcrumb">
			<li>
				<a href="/business/get_bus_business/" > 返回业务管理</a> <span class="divider">/</span><!--onclick="javascript:history.go(-1)"-->
				<a href="/business/one_business/{{ old_business }}/" > 返回{{ old_business }}管理</a> <span class="divider">/</span>
			</li>
			<li>
				{{ old_business }} pos管理
			</li>
		</ul>
	</div>
<!--=============================pos========begin================================================== -->
<div class="row-fluid sortable">
	<div class="box span12">
		<div class="box-header well" data-original-title>
			<h2><i class="icon-th"></i>pos 管理</h2>
		</div>
		<div class="row-fluid" style="margin-left:450px">
				上游:
				<select id="pos_src_add">
						<option value="0">----select-----</option>
					{% for value in business_src_data %}
						<option value="{{value.port}}" {% ifequal src value.port  %} selected {% endifequal %}>{{value.port}}</option>
					{% endfor %}
				</select>
				下游:
				<select id="pos_dist_add">
						<option value="0">----select-----</option>
					{% for value in business_target_data %}
						<option value="{{value.port}}" {% ifequal dist value.port  %} selected {% endifequal %} >{{value.port}}</option>
					{% endfor %}
				</select>&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button" class="btn btn-small btn-info" onclick="pos_search()" value="搜索">
		</div>
		<br/>
		<div class="box-content" id="box-content">	
<table class="table table-striped table-bordered bootstrap-datatable datatable">
	<thead>
		<tr>
			<th>上游</th>
			<th>下游</th>
			<th>pos值</th>
			<th>延迟</th>
			<th> 操作</th>
		</tr>
	</thead>
	<tbody>
		{% ifnotequal src '0' %}
		{% ifequal dist '0' %}
		{% for value in business_src_data %}
			{% ifequal src value.port  %}
			<tr>
				<td>{{ value.ip }}:{{ value.port }}</td>
				<td>all</td>
				<td><input type="text" value="None" id="{{ value.ip }}_{{ value.port }}_all" /></td>
				<td>None</td>
				<td>
					<input value="修改" style="background:#F75000" type="button" class="btn btn-primary" onclick="modify_all_pos('{{ old_business }}', '{{ value.ip }}', '{{ value.port }}')" />
				</td>
			</tr>
			{% endifequal %}
		{% endfor %}
		{% endifequal %}
		{% endifnotequal %}

		{% for value in all_pos_list %}
		<tr>
			<td>{{ value.src_ip_port }}</td>
			<td>{{ value.dst_ip_port}}</td>
			<td><input type="text" value="{{ value.pos_value }}" id="{{ value.src_ip_port}}_{{ value.dst_ip_port }}_value" /></td>
			<td>{{ value.delay}}</td>
			<td>
			<input value="修改" type="button" class="btn btn-primary" onclick="modify_pos('{{ old_business }}', '{{ value.src_ip_port }}', '{{ value.dst_ip_port }}')" />
			</td>
		</tr>
		{% endfor %}
	</tbody>
</table>			
		</div>
	</div>
</div>
<!--=============================pos========end================================================== -->


<!-- content ends -->

 <!-- external javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->

<!-- jQuery -->
<script src="{% get_static_prefix %}charisma/js/jquery-1.7.2.min.js"></script>
<script src="{% get_static_prefix %}charisma/js/jquery-ui-1.8.21.custom.min.js"></script>
<script language="JavaScript" type="text/javascript">
	$(document).ready(function() {
	});;   
	function pos_search(){
		var pos_src_add = $("#pos_src_add").val();
		var pos_dist_add = $("#pos_dist_add").val();
		window.location.href="/business/show_pos/{{ old_business }}/?dist="+pos_dist_add+"&src="+pos_src_add;
	}
	function modify_pos(curbuss, src_ip_port, dst_ip_port){
		var pos_value_id= src_ip_port + "_" + dst_ip_port + "_value";
		var pos_value= document.getElementById(pos_value_id).value;
		$.ajax({
             type: "GET",
             url: "/business/modify_pos/?business=" + curbuss + "&src_ip_port="  + src_ip_port + "&dst_ip_port=" + dst_ip_port + "&pos_value=" + pos_value,
             success: function(data){
		if (data == "ok") {
		 alert("修改位置点成功");
                 location.reload();
		} else {
		alert("修改位置点失败,error:" + data);
                 location.reload();
             }},
             error:function(){
             	alert("modify_pos.... error, 请联系管理员");
             }
         });	
	}
	function modify_all_pos(curbuss, src_ip, src_port){
		var pos_value_id= src_ip + "_" + src_port + "_all";
		var pos_value= document.getElementById(pos_value_id).value;
		$.ajax({
             type: "GET",
             url: "/business/modify_all_pos/?business=" + curbuss + "&src_ip="  + src_ip + "&src_port=" + src_port + "&pos_value=" + pos_value,
             success: function(data){
		if (data == "ok") {
		 alert("修改所有位置点成功");
                 location.reload();
		} else {
		alert("修改所有位置点失败,error:" + data);
                 location.reload();
             }},
             error:function(){
             	alert("modify_pos.... error, 请联系管理员");
             }
         });	
	}
</script>
</body>
</html>
